﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using orienta.Models;

namespace orienta.Utils
{

    public static class Cache
    {
        public static Hashtable hashtable = new Hashtable();


        public static List<ORIDetCompendio> getListCompendio(decimal id)
        {
            GoodTireEntities db = new GoodTireEntities();
            List<ORIDetCompendio> lista = null;
            if (hashtable.Contains(id))
            {
                lista = (List<ORIDetCompendio>)hashtable[id];

            }
            else
            {
                lista = db.ORIDetCompendio.Where<ORIDetCompendio>(o => o.nIdeCompendio == id && (o.dtFecFinVig ==null || o.dtFecFinVig > DateTime.Now)).ToList();
                hashtable.Add(id, lista);
            }

            return lista;


        }

        public static void actualizarCompendio(decimal id)
        {
            GoodTireEntities db = new GoodTireEntities();
            List<ORIDetCompendio> lista = db.ORIDetCompendio.Where<ORIDetCompendio>(o => o.nIdeCompendio == id && (o.dtFecFinVig == null || o.dtFecFinVig > DateTime.Now)).ToList();
            
            if (hashtable.Contains(id))
            {
                hashtable[id] = lista;

            }
            else
            {
                hashtable.Add(id, lista);
            }



        }

    }
}